package com.example.exception;

/**
 * 错误码枚举
 * 
 * 错误码格式：XXYYZZ
 * - XX: 模块代码
 * - YY: 错误类型
 * - ZZ: 具体错误序号
 * 
 * @author Means
 * @since 2025-10-27
 */
public enum ErrorCode {
    
    // ========== 通用错误 (00xxxx) ==========
    SUCCESS("000000", "操作成功"),
    SYSTEM_ERROR("000001", "系统错误"),
    PARAMETER_ERROR("000002", "参数错误"),
    RESOURCE_NOT_FOUND("000003", "资源不存在"),
    OPERATION_FAILED("000004", "操作失败"),
    UNAUTHORIZED("000005", "未授权"),
    FORBIDDEN("000006", "禁止访问"),
    REQUEST_LIMIT("000007", "请求过于频繁"),
    
    // ========== 商品模块 (01xxxx) ==========
    PRODUCT_NOT_FOUND("010001", "商品不存在"),
    PRODUCT_ALREADY_EXISTS("010002", "商品已存在"),
    PRODUCT_INACTIVE("010003", "商品未上架"),
    PRODUCT_DELETED("010004", "商品已删除"),
    PRODUCT_IN_ACTIVE_PRICE_LIST("010005", "商品在激活的价目表中，无法下架"),
    
    // ========== 价目表模块 (02xxxx) ==========
    PRICE_LIST_NOT_FOUND("020001", "价目表不存在"),
    PRICE_LIST_INACTIVE("020002", "价目表未激活"),
    PRICE_ENTRY_NOT_FOUND("020003", "价格条目不存在"),
    NO_EFFECTIVE_PRICE_LIST("020004", "当前无生效的价目表"),
    PRICE_NOT_CONFIGURED("020005", "商品价格未配置"),
    
    // ========== 单位换算模块 (03xxxx) ==========
    UNIT_NOT_FOUND("030001", "计量单位不存在"),
    CONVERSION_RULE_NOT_FOUND("030002", "单位换算规则不存在"),
    CONVERSION_NOT_SUPPORTED("030003", "不支持的单位换算"),
    INVALID_QUANTITY("030004", "无效的数量"),
    
    // ========== 购物车模块 (04xxxx) ==========
    CART_NOT_FOUND("040001", "购物车不存在"),
    CART_EMPTY("040002", "购物车为空"),
    CART_ITEM_NOT_FOUND("040003", "购物车商品不存在"),
    CART_INACTIVE("040004", "购物车不可用"),
    
    // ========== 订单模块 (05xxxx) ==========
    ORDER_NOT_FOUND("050001", "订单不存在"),
    ORDER_CANNOT_MODIFY("050002", "订单不可修改"),
    ORDER_ALREADY_PAID("050003", "订单已支付"),
    ORDER_PAYMENT_FAILED("050004", "订单支付失败"),
    ORDER_CANCELLED("050005", "订单已取消"),
    INVALID_ORDER_STATUS("050006", "无效的订单状态"),
    
    // ========== 促销规则模块 (06xxxx) ==========
    PRICING_RULE_NOT_FOUND("060001", "促销规则不存在"),
    PRICING_RULE_INACTIVE("060002", "促销规则未启用"),
    PRICING_RULE_EXPIRED("060003", "促销规则已过期"),
    DISCOUNT_CALCULATION_ERROR("060004", "折扣计算错误"),
    
    // ========== 支付模块 (07xxxx) ==========
    PAYMENT_FAILED("070001", "支付失败"),
    PAYMENT_TIMEOUT("070002", "支付超时"),
    INVALID_PAYMENT_AMOUNT("070003", "无效的支付金额"),
    
    ;
    
    private final String code;
    private final String message;
    
    ErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getMessage() {
        return message;
    }
}

